import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { join } from "node:path";

export default defineConfig({
  plugins: [vue()],
  resolve: {
    extensions: [".js", ".ts", ".tsx", ".jsx", "vue"],
    alias: [
      {
        find: "@",
        replacement: join(__dirname, "src"),
      },
      {
        find: "leisure-lib/dist/style/index.less",
        replacement: join(__dirname, "..", "style", "index.less"),
      },
      {
        find: "leisure-lib",
        replacement: join(__dirname, "..", "src", "index.ts"),
      },
      {
        find: /^@leisure-lib\/(.+)$/,
        replacement: join(__dirname, "..", "packages", "$1", "index.ts"),
      },
    ],
  },
  server: {
    port: 3001,
    host: true,
    proxy: {
      "/api": {
        target: "http://127.0.0.1:3005",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
    },
  },
});
